<template>
  <div>
    <div class="bpmn-viewer-container">
      <process-pic-detail :proc-inst-id="procInstId"></process-pic-detail>
      <a-card title="审批记录" bordered>
        <a-table
          ref="table"
          bordered
          size="middle"
          :rowKey="(r,p)=>{return p}"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="false"
          :loading="loading">

        </a-table>
      </a-card>
    </div>
  </div>
</template>

<script>

  import {getAction} from '@/api/manage'
  import ProcessPicDetail from "./ProcessPicDetail";

  export default {
    props: {
      procInstId: {
        type: String,
      },
      bussiColumns: {
        type: Array,
        default: () => {
          return [];
        }
      },
      auditHisUrl: {
        type: String,
        default: '',
      }
    },
    name: 'reviewRuningFlow',
    components: {ProcessPicDetail},
    data() {
      return {
        title: '流程预览',
        loading: false,
        dataSource: [],
        columns: [
          {
            title: '流程ID',
            dataIndex: 'procInstId',
            width: 150,
            align: 'center',
            ellipsis: true,
          },
          {
            title: '任务ID',
            dataIndex: 'taskId',
            width: 150,
            align: 'center',
            ellipsis: true,
          },
          {
            title: '审核人',
            dataIndex: 'opUserId',
            width: 150,
            align: 'center',
            ellipsis: true,
          },
          {
            title: '审核时间',
            dataIndex: 'opTime',
            width: 120,
            align: 'center',
            ellipsis: true,
          },
          {
            title: '审核理由',
            dataIndex: 'remarks',
            width: 120,
            align: 'center',
            ellipsis: true,
          },
        ],
        url: {
          getAuditComment: '/process/getAuditCommentList'
        }
      }
    },
    created() {
      this.getAuditComment();
    },
    methods: {
      getAuditComment() {
        if (!this.auditHisUrl && this.bussiColumns.length == 0) {
          getAction(this.url.getAuditComment, {proInsanceId: this.procInstId}).then(res => {
            if (res.success) {
              this.dataSource = res.result;
            }
          });
        }else {
          this.columns = [...this.bussiColumns];
          getAction(this.auditHisUrl, {proInsanceId: this.procInstId}).then(res => {
            if (res.success) {
              this.dataSource = res.result;
            }
          });
        }
      },
    },
  }
</script>

